﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="queryqrcode.aspx.cs" Inherits="bzxxxt.admin.ashx.queryqrcode" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>二维码打印</title>
    <script src="../js/jquery.min.js"></script>
    <object id="ArgoxPrinter" classid="clsid:AEFC7183-44DE-463c-ACEF-8CAF33B96701" codebase="ArgoxWebPrint.cab"></object>
    <script type="text/javascript">

        function PrinterSetup() {
            try {
                ArgoxPrinter.A_EnumUSB();
                ArgoxPrinter.A_CreateUSBPort(1);
                //1英寸(in)=25.4毫米(mm) 1厘米(cm)=0.3937008英寸(in)
                ArgoxPrinter.A_Set_Unit("n");	                //n: 英吋, m:公厘。
                ArgoxPrinter.A_Set_Syssetting(2, 0, 0, 0, 0);
                ArgoxPrinter.A_Set_Backfeed(320);		        //回退值
                ArgoxPrinter.A_Set_Darkness(8);
                ArgoxPrinter.A_Set_Speed("E");
            } catch (e) {
                alert("打印未接入或驱动安装不正确，请检查打印！");
                return;
            }

            var url = "http://localhost:14848/admin/ashx/querydeadinfo.aspx?code=05210013000088A1";
            var leftmargin = document.getElementById("leftmargin").value;
            var bottommargin = document.getElementById("bottommargin").value;
            var x = parseInt(leftmargin);
            var y = parseInt(bottommargin);

            //(标签纸大小[0.01英寸]:197,157) 
            ArgoxPrinter.A_Draw_Box("A", x - 2, y - 2, 197 - x * 2 + 2, 157 - y * 2 + 2, 2, 2);
            ArgoxPrinter.A_Prn_Text_TrueType(x, y + 10, 30, "宋体", 1, 600, 0, 0, 0, "A1", "Argox 打印机设定完成！", 1);
            ArgoxPrinter.A_Prn_Text_TrueType(x, y + 25, 30, "宋体", 1, 600, 0, 0, 0, "A2", "单位：吋", 1);
            ArgoxPrinter.A_Prn_Text_TrueType(x, y + 40, 30, "宋体", 1, 600, 0, 0, 0, "A3", "打印模式：热转印", 1);
            ArgoxPrinter.A_Prn_Text_TrueType(x, y + 55, 30, "宋体", 1, 600, 0, 0, 0, "A4", "打印机端口：USB", 1);
            ArgoxPrinter.A_Prn_Text_TrueType(x, y + 70, 30, "宋体", 1, 600, 0, 0, 0, "A5", "打印浓度：8", 1);
            ArgoxPrinter.A_Prn_Text_TrueType(x, y + 85, 30, "宋体", 1, 600, 0, 0, 0, "A6", "打印速度：3 ips", 1);
            ArgoxPrinter.A_Prn_Text_TrueType(x, y + 100, 30, "宋体", 1, 600, 0, 0, 0, "A7", "倒退位移：开启 (1吋)", 1);

            x = x + 205;
            ArgoxPrinter.A_Prn_Text_TrueType(x, y, 30, "宋体", 4, 600, 0, 0, 0, "A8", "测试姓名", 1);
            ArgoxPrinter.A_Prn_Text_TrueType(x + 20, y, 24, "宋体", 4, 600, 0, 0, 0, "A9", "01234567890123A3", 1);
            ArgoxPrinter.A_Draw_Line("A", x + 40, y, 1, 110);
            ArgoxPrinter.A_Bar2d_QR(x + 50, y, 1, '6', 1, 'N', 1, url);


            ArgoxPrinter.A_Print_Out(1, 1, 1, 1);

            ArgoxPrinter.A_ClosePrn();
        }

        function Print() {
            try {
                var dead = [];
                $('input[type="checkbox"]:checked').each(function () {
                    var d = {};
                    d.did = $(this).val();
                    d.code = $('#deadcode' + d.did).text();
                    d.name = $('#deadname' + d.did).text();
                    d.url = $('#url' + d.did).val();
                    dead.push(d);
                });
                var volstr = document.getElementById("volume").value;
                var txtip = document.getElementById("txtIP").value;
                if (document.getElementById("r1").checked) {
                    ArgoxPrinter.A_EnumUSB();
                    ArgoxPrinter.A_CreateUSBPort(1);
                }
                else if (document.getElementById("r2").checked) {
                    ArgoxPrinter.A_CreatePort(5, 0, txtip);
                }
                var leftmargin = document.getElementById("leftmargin").value;
                var bottommargin = document.getElementById("bottommargin").value;
                var x = parseInt(leftmargin);
                var y = parseInt(bottommargin);
                for (var i = 0; i < dead.length; i++) {
                    var did = dead[i].did;
                    var url = dead[i].url;
                    var name = dead[i].name;
                    var code = dead[i].code;
                    x = parseInt(leftmargin);
                    ArgoxPrinter.A_Prn_Text_TrueType(x, y, 30, "宋体", 4, 600, 0, 0, 0, "N" + did, name, 1);
                    ArgoxPrinter.A_Prn_Text_TrueType(x + 20, y, 24, "宋体", 4, 600, 0, 0, 0, "C" + did, code, 1);
                    ArgoxPrinter.A_Draw_Line("A", x + 40, y, 1, 110);
                    ArgoxPrinter.A_Bar2d_QR(x + 50, y, 1, '6', 1, 'N', 1, url);
                    //第二排  0.254*50
                    x = x + 205;
                    ArgoxPrinter.A_Prn_Text_TrueType(x, y, 30, "宋体", 4, 600, 0, 0, 0, "N2" + did, name, 1);
                    ArgoxPrinter.A_Prn_Text_TrueType(x + 20, y, 24, "宋体", 4, 600, 0, 0, 0, "C2" + did, code, 1);
                    ArgoxPrinter.A_Draw_Line("A", x + 40, y, 1, 110);
                    ArgoxPrinter.A_Bar2d_QR(x + 50, y, 1, '6', 1, 'N', 1, url);
                    ArgoxPrinter.A_Print_Out(1, 1, volstr, 1);
                }
                ArgoxPrinter.A_ClosePrn();
            } catch (e) {
                alert("打印出错，请检查打印机！");
            }
        }

        function PrinterStatus() {
            ArgoxPrinter.A_EnumUSB();
            ArgoxPrinter.A_CreateUSBPort(1);
            var ret = ArgoxPrinter.A_getPrinterStatus();
            if (ret == 0) {
                document.getElementById("status").value = "无返回值";
                return;
            }
            else if (ret == 1) {
                document.getElementById("status").value = "打印机命令解析器忙碌中！";
                return;
            }
            else if (ret == 2) {
                document.getElementById("status").value = "2 纸张用完或安装错误！";          //纸张用完或安装错误！
                return;
            }
            else if (ret == 4) {
                document.getElementById("status").value = "4 碳带用完或安装错误！";                       //碳带用完或安装错误！";
                return;
            }
            else if (ret == 8) {
                document.getElementById("status").value = "8 打印批次文档中！";           //打印批次文档中！";
                return;
            }
            else if (ret == 16) {
                document.getElementById("status").value = "16 正在打印文件！";                 //正在打印文件！
                return;
            }
            else if (ret == 32) {
                document.getElementById("status").value = "32 打印机暂停！";                 //打印机暂停！
                return;
            }
            else if (ret == 64) {
                document.getElementById("status").value = "64 正在送出标签纸！";                 //正在送出标签纸！
                return;
            }
            else if (ret == 9) {
                document.getElementById("status").value = "9 打印机待机中！";                 //打印机待机中！
                return;
            }
            ArgoxPrinter.A_ClosePrn();
        }

    </script>

    <style>
        table tr td
        {
            text-align: left;
            margin-left: 20px;
            padding-left: 20px;
        }

    </style>
</head>
<body>
    <form id="form1" runat="server">
    
    <div style="text-align:center" >
        <asp:DataList ID="DataList1" align="center" runat="server" RepeatDirection="Horizontal" RepeatColumns="3">
            <ItemTemplate>
                <table style="margin-bottom:10px">
                    <tr>                        
                        <td colspan="2">
                            <span id='deadname<%#Eval("deadid")%>'><%#Eval("deadname") %></span>
                        </td>    
                    </tr>
                    <tr>                        
                        <td colspan="2">
                            <span id='deadcode<%#Eval("deadid")%>'><%#Eval("deadcode") %></span>
                        </td>
                                            
                    </tr>
                    <tr>
                        <td colspan="2" >
                            <input type="hidden" id='url<%#Eval("deadid")%>'  value="<%#Eval("url")%>" />
                            <img id='qrcode<%#Eval("deadid")%>' src="<%#Eval("qrcodeurl") %>" alt="" style="width:150px; height:150px"  />
                        </td>                        
                    </tr>
                    <td colspan="2">
                            <input type="checkbox" checked="checked" name='deadid<%#Eval("deadid")%>' value="<%#Eval("deadid")%>" />打印                           
                        </td> 
                    
                    <tr style="display:none">
                        <td>联系人姓名:</td>
                        <td>
                            <span id='relativename<%#Eval("deadid")%>'><%#Eval("relativename") %></span>
                        </tr>
                    <tr style="display:none">
                        <td>联系人电话:</td>
                        <td>
                            <span id='relativetel<%#Eval("deadid")%>'><%#Eval("relativetel") %></span>
                        </td>
                    </tr>
                </table>
            </ItemTemplate>
        </asp:DataList>
        <hr />
        <table style="width:600px;" align="center">
            <tr>
                <td style="width:30%">
                    <input type="button" value="开始打印" style="width: 95px" onclick="Print()" />
                    
                </td>
                <td colspan="2">份数：<input type="text" name="volume" id="volume" value="1" style="width:20px" />
				&nbsp;&nbsp;&nbsp;左边距:<input type="text" name="leftmargin" id="leftmargin" value="20" style="width:20px" />
				&nbsp;&nbsp;&nbsp;下边距:<input type="text" name="bottommargin" id="bottommargin" value="20" style="width:20px" />
                
                    &nbsp;                    
                </td>
            </tr>
            <tr>
                <td>
                    <input type="button" value="打印机设置" style="width: 95px" onclick="PrinterSetup()" />
                </td>
                <td class="center" style="width: 166px">打印机状态查询：
                </td>
                <td>
                    <input type="button" value="开始查询" style="width: 95px" onclick="PrinterStatus()" />
                </td>
            </tr>
            <tr>

                <td>打印机状态：
                </td>
                <td colspan="2">
                    <input type="text" style="width:95%" name="status" id="status" readonly="readonly" />
                </td>
            </tr>

            <tr>
                <td>打印接口：
                </td>
                <td>
                    <input type="radio" name="radio1" id="r1" checked="checked" />USB打印
                </td>
                <td>
                    <input type="radio" name="radio1" id="r2" />LAN打印
                </td>
            </tr>
            <tr>
                <td>请输入IP地址:
                </td>
                <td colspan="2">
                    <input type="text" name="txtIP" id="txtIP" />(LAN打印请填写IP)
                </td>
            </tr>
           <tr>
               <td colspan="3">
                   <br />
                   <b>打印机复位：</b><br />
                    (1) 打开打印机电源，等待5秒以上；  <br />
                    (2) 准备就绪后，按住键不放，直到＂READY＂和＂POWER＂指示灯依次熄灭； <br />
                    (3) 当两个指示灯再次亮起时，放开按键。<br />
               </td>
           </tr>
                <tr>
               <td colspan="3">
                <b>测纸校准操作：</b><br />
                (1)关闭打印机电源； <br />
                (2)持续按住打印机前方的FEED键，同时打开打印机电源；  <br />
                (3)打印机开始走空白标签后，放开FEED键。
               </td>
           </tr>
        </table>
    </div>
    </form>
    <a href="/admin/upload/ArgoxWebPrintSetup.msi" target="_blank">打印机驱动下载安装</a>
</body>
</html>